<template>
	<view class="home">
		<!-- 自定义导航栏 -->
		<navbar></navbar>
		<tabs :list="tabLists" :tabIndex="tabIndex" @tabClick="tabClick"></tabs>
		<!-- <view class="scroll">
			<scroll-view scroll-y class="list-scroll">
				<view v-for="item in 1000">
					{{item}}
				</view>
			</scroll-view>
		</view> -->
		<view class="home-list">
			<list :tabLists="tabLists" :activeIndex="activeIndex" @change="change"></list>
		</view>
	</view>
</template>

<script>
	// easyCom components/组件名/组件名.vue
	// import navbar from '@/components/navbar/navbar.vue'
	// import { callFunction } from '../../../utils/asyncUni.js'
	export default {
		data() {
			return {
				title: 'Hello',
				tabLists: [],
				// 上方导航的下标
				tabIndex: 0,
				// 下方视图的下标
				activeIndex: 0
			}
		},
		// components: {
		// 	navbar
		// },
		onLoad() {
			this.getLabel()
		},
		methods: {
			// 调用云函数 获取列表数据
			async getLabel() {
				const { result } = await this.$api.callFunction({
					name: 'get_label'
				})
				// console.log(result)
				result.data.unshift({
					name: '全部'
				})
				this.tabLists = result.data
			},
			tabClick({ item, index }) {
				// console.log(item, index)
				this.activeIndex = index
			},
			change(current) {
				// console.log(current)
				this.tabIndex = current
				this.activeIndex = current
			},
		}
	}
</script>

<style lang='scss'>
	page {
		display: flex;
		height: 100%;
		.home {
			display: flex;
			flex: 1;
			flex-direction: column;
			overflow: hidden;
			.home-list {
				flex: 1;
				box-sizing: border-box;
			}
		}
	}
</style>
